<?php
/*
+ --------------------------------------------------- +
|  Ineo Article Manager - Version 2.x
|  Copyright 2006-2007, Dan Cryer and William McGann
+ --------------------------------------------------- +

Ineo Article Manager is free software; you can redistribute it and/or modify
it under the terms of version 3 of the GNU General Public License as published by
the Free Software Foundation.

Ineo Article Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Ineo; see the file License.txt.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

*/

/**
* Installer - Step 2 - Add Component:
*/
class install_step_2
{
	var $refresh_after_step = true;
	var $await_input        = false;
	
	function install_step_2( &$installer )
	{
		$this->installer =& $installer;
		$this->ipsclass  =& $installer->ipsclass;
	}
	
	function run_step()
	{
		// Load component array from XML file:
		$this->ipsclass->xml->xml_parse_document( file_get_contents($this->installer->data_dir.'ineo_component.xml') );
		$com_array_tmp = $this->ipsclass->xml->xml_array;
		$com_array_tmp = $com_array_tmp['componentexport']['componentgroup']['component'];
		
		foreach ( $com_array_tmp as $key => $value )
		{
		  $com_array[$key] = $value['VALUE'];
		}

		// Set com_section_key so it doesn't have fits.
		$com_array['com_section_key'] = 'ineo';
		
		// Load IPB API core:
		require( ROOT_PATH . 'sources/api/api_core.php' );
		$api_core = new api_core();
		$api_core->ipsclass =& $this->ipsclass;
		
		// Load IPB Components API:
		require( ROOT_PATH . 'sources/api/api_components.php' );
		$api = new api_components();
		$api->ipsclass =& $this->ipsclass;
		
		
		// Insert Component:
		$api->acp_component_insert( 'ineo', $com_array );
		
		// Set status text:
		$this->installer->status_text .= 'Component information added to the database.<br />';
	}
}

?>